/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet.registration;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author HONEY
 */

@WebServlet(name = "addtoexperiencebean", urlPatterns = {"/addtoexperiencebean"})
public class addtoexperiencebean extends HttpServlet {

   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        
        AO.Seeker s=(AO.Seeker)request.getSession().getAttribute("seekerdata");
        AO.Login l=(AO.Login)request.getSession().getAttribute("logindata");
        String username=s.getUsername();
        AO.Experience exp=new AO.Experience();
        int i=1;
        if(!request.getParameter("experience1").equals("")){helper.SeekerHelper.updateStatus("fresher",username);
        
        
        while(!request.getParameter("experience"+i).equals(""))
        {
            
            exp.setUsername(username);
            exp.setExperience(request.getParameter("experience"+i));
            exp.setCompany(request.getParameter("company"+i));
            exp.setDesignation(request.getParameter("designation"+i));
            exp.setSalary(request.getParameter("salary"+i));
            exp.setCompanyAddress(request.getParameter("companyaddress"+i));
            DAO.ExperienceDAO.save(exp);
            i++;
        }
        
        //response.sendRedirect("seeker/");
        response.sendRedirect("seeker/");
        }
        
    }
       

    

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }


    @Override
    public String getServletInfo() {
        return "Short description";
    }
}
